package com.iceengine.j3d.camera;

/**
 * Basic camera example that implements ICamera.
 * @author penguin
 */
import org.lwjgl.util.vector.*;

public class BasicCamera implements ICamera {
    private Vector3f translation;
    private Vector3f rotation;

    /**
     * Creates a basic camera.
     */
    public BasicCamera()
    {
        translation = new Vector3f(0,0,0);
        rotation = new Vector3f(0,0,0);
    }
    public void moveForward(float ammount)
    {
        translation.x += (float)Math.sin(rotation.y *(Math.PI/180)) * ammount;
        translation.z += (float)Math.cos(rotation.y * (Math.PI/180)) * ammount;
    }
    public void moveBackward(float ammount)
    {
        translation.x -= (float)Math.sin(rotation.y *(Math.PI/180)) * ammount;
        translation.z -= (float)Math.cos(rotation.y * (Math.PI/180)) * ammount;
    }
    public void moveLeft(float ammount)
    {
        translation.x -= ammount * (float)Math.sin(Math.toRadians(rotation.y-90));
        translation.z -= ammount * (float)Math.cos(Math.toRadians(rotation.y-90));
    }
    public void moveRight(float ammount)
    {
        translation.x -= ammount * (float)Math.sin(Math.toRadians(rotation.y+90));
        translation.z -= ammount * (float)Math.cos(Math.toRadians(rotation.y+90));
    }
    public void LookUp(float ammount)
    {
        if(rotation.x > -90)
            rotation.x -= ammount;
    }
    public void LookDown(float ammount)
    {
        if(rotation.x < 90)
            rotation.x += ammount;
    }
    public void LookLeft(float ammount)
    {
        if(rotation.y < 90)
        {
            rotation.y += ammount;
        }
    }
    public void LookRight(float ammount)
    {
        if(rotation.y > -90)
        {
            rotation.y -= ammount;
        }
    }

    public Vector3f getTranslation()
    {
        return translation;
    }
    public Vector3f getRotation()
    {
        return rotation;
    }
}
